<?php

/**
 * Tiers.php
 */

namespace RHX\Model\Object;

use Zend\Db\Adapter\Adapter;

/**
 * Classe Tiers
 */
class Tiers{

    public $id;
    public $libelle;
    public $contact;
    public $adresse;
    public $siret ;
    public $website;
    public $phone  ;
    public $fax ;
    public $mail;
    public $photo;
    public $rib;
    
    public $lundi;
    public $lundi_ouverture;
    public $lundi_fermeture;
    public $mardi;
    public $mardi_ouverture;
    public $mardi_fermeture;
    
    public $mercredi;
    public $mercredi_ouverture;
    public $mercredi_fermeture;
    
    public $jeudi;
    public $jeudi_ouverture;
    public $jeudi_fermeture;
    
    public $vendredi;
    public $vendredi_ouverture;
    public $vendredi_fermeture;
    
    public $samedi;
    public $samedi_ouverture;
    public $samedi_fermeture;
    
    public $dimanche;
    public $dimanche_ouverture;
    public $dimanche_fermeture;
    
    protected $adapter;
    /**
     * Constructeur
     *
     * @param array $data
     */
    public function __construct(Adapter $adapter, $data = array()) {
        $this->adapter = $adapter;
	$this->exchangeArray($data);
    }

    /**
     * Remplissage des données
     *
     * @param array $data
     */
    public function exchangeArray($data) {
	$this->id	 = isset($data['id']) ? $data['id'] : 0;
	$this->libelle	 = isset($data['libelle']) ? $data['libelle'] : '';
	$this->contact	 = isset($data['contact']) ? $data['contact'] : '';	
        $this->adresse	 = isset($data['adresse']) ? $data['adresse'] : '';	
        
        $this->siret	 = isset($data['siret']) ? $data['siret'] : '';
	$this->website	 = isset($data['website']) ? $data['website'] : '';	
        $this->phone  	 = isset($data['phone']) ? $data['phone'] : '';	        
        $this->fax   	 = isset($data['fax']) ? $data['fax'] : '';	
        $this->mail   	 = isset($data['mail']) ? $data['mail'] : '';	
        
        $this->photo   	 = isset($data['photo']) ? $data['photo'] : '';	
	$this->rib   	 = isset($data['rib']) ? $data['rib'] : '';	
        
        // horaire
        $dWk = array('lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche') ;
        
        foreach ($dWk as $d ){
            $d_ouv = $d. '_ouverture' ; $d_fer = $d. '_fermeture';
            $this->$d = isset($data[$d]) ? $data[$d] : 0;
            $this->$d_ouv			 = isset($data[$d_ouv]) ? $data[$d_ouv] : '00:00';
            $this->$d_fer			 = isset($data[$d_fer]) ? $data[$d_fer] : '00:00';
        }
    }

    /**
     * Copie en Tableau des données
     * 
     * @return array
     */
    public function getArrayCopy() {
	return get_object_vars($this);
    }
}

?>
